<#include "../common/common.ftl"/>
<table class="layui-table">
    <tr class="layui-bg-gray">
        <th style="text-align: center;width: 3%;" rowspan="2">序号</th>
        <th style="text-align: center;" rowspan="2">安置项目</th>
        <th style="text-align: center;" colspan="5">安置房源信息</th>
<#--
        <th style="text-align: center;" colspan="2">储藏室信息</th>
-->
        <th style="text-align: center;width: 16%;" rowspan="2">操作</th>
    </tr>
    <tr class="layui-bg-gray">
        <th style="text-align: center;">房源信息</th>
        <th style="text-align: center;">房屋类型</th>
        <th style="text-align: center;">房屋户型</th>
        <th style="text-align: center;">总建筑面积(套内建筑面积+公摊面积)</th>
        <th style="text-align: center;">调节金额</th>
       <#-- <th style="text-align: center;">储物间信息</th>
        <th style="text-align: center;">建筑面积</th>-->
    </tr>
<#list houseList as house>
    <#assign storageRoom=resultMap[house.id?c]/>
    <tr>
        <td style="text-align: center;">${house_index+1}</td>
        <td style="text-align: center;">${(house.azProject.projectName)!}</td>
        <td style="text-align: center;">${(house.houseNumStr)!}【${(house.floor)!}层】</td>
        <td style="text-align: center;">${(houseTypeMap[house.houseType].name)!}</td>
        <td style="text-align: center;">${(houseHoldMap[house.houseHold].name)!}</td>
        <td style="text-align: center;">${(house.buildArea)!}【<span
                class="jmdf-color-red">${(house.propertyArea)!}</span>+<span
                class="jmdf-color-red">${(house.poolArea)!}</span>】
        </td>
        <td style="text-align: center;">${(house.tjMoney)!}</td>

        <#if (storageRoom.id??)>
            <#--<td style="text-align: center;">${(storageRoom.houseNumStr)!}【${(storageRoom.floor)!}层】</td>
            <td style="text-align: center;">${(storageRoom.buildArea)!}</td>-->
        <#else>
          <#--  <td style="text-align: center;"></td>
            <td style="text-align: center;"></td>-->
        </#if>
        <th style="text-align: center;">
            <#if (contract.chooseHouseStatus == 1)>
                <#if (house.houseType != "02")>
                    <#if (storageRoom.id??)>
                        <a class="layui-btn layui-btn-xs layui-btn-danger storageRoomDelete"
                           buildNum="${(storageRoom.buildNum)!}" houseNum="${(storageRoom.houseNum)!}"
                           storageRoomId="${storageRoom.id}"><i class="layui-icon layui-icon-delete"></i>撤销储藏室</a>
                    <#else>
                        <a class="layui-btn layui-btn-xs layui-btn-danger houseDelete" buildNum="${(house.buildNum)!}"
                           houseNum="${(house.houseNum)!}" houseId="${house.id}"><i
                                class="layui-icon layui-icon-delete"></i>撤销房源</a>
                    </#if>
                <#else>
                    <#if !(storageRoom.id??)>
                        <a class="layui-btn layui-btn-xs layui-btn-danger houseDelete" buildNum="${(house.buildNum)!}"
                           houseNum="${(house.houseNum)!}" houseId="${house.id}"><i
                                class="layui-icon layui-icon-delete"></i>撤销房源</a>
                    </#if>
                </#if>
            </#if>
        </th>
    </tr>
</#list>
<#list noHouseStorageRoomList as storageRoom>
    <tr>
        <td style="text-align: center;">${storageRoom_index+1}</td>
        <td style="text-align: center;"></td>
        <td style="text-align: center;"></td>
        <td style="text-align: center;"></td>
        <td style="text-align: center;"></td>
        <td style="text-align: center;"></td>
        <td style="text-align: center;"></td>
        <#if (storageRoom.id??)>

                <td style="text-align: center;">${(storageRoom.houseNumStr)!}【${(storageRoom.floor)!}层】</td>
                <td style="text-align: center;">${(storageRoom.buildArea)!}</td>
            <#if (contract.chooseHouseStatus == 1)>

                <th style="text-align: center;">
                    <a class="layui-btn layui-btn-xs layui-btn-danger storageRoomDelete"
                       buildNum="${(storageRoom.buildNum)!}"
                       houseNum="${(storageRoom.houseNum)!}" storageRoomId="${storageRoom.id}"><i
                            class="layui-icon layui-icon-delete"></i>撤销储藏室</a>
                </th>
            </#if>
        </#if>
    </tr>
</#list>

    <tr class="layui-bg-gray">
        <td colspan="5" style="text-align: right;">合计：</td>
        <td style="text-align: center;"><span class="jmdf-color-red">${(contract.chooseHouseAreaTotal)!}【${(contract.limitHouseAreaTotal-contract.chooseHouseAreaTotal)!}】</span></td>
        <td style="text-align: center"><span class="jmdf-color-red">${(contract.tjMoneyTotal)!}</span></td>
        <td></td>
        <#--<td style="text-align: center;"><span class="jmdf-color-red">${(contract.storageRoomArea)!}</span></td>
        <td></td>-->
    </tr>
</table>
<script>
    layui.config({
        base: '/modules/' //静态资源所在路径
    }).use(['jquery', 'layer', 'jmdf'], function () {
        var $ = layui.jquery, layer = layui.layer, jmdf = layui.jmdf;

        $(".houseDelete").click(function () {
            var obj = $(this);
            layer.open({
                title: false,
                shade: 0.5,
                content: "确定撤销【" + obj.attr("buildNum") + "幢" + obj.attr("houseNum") + "】房源吗？",
                btn: ['确定', '取消'],
                closeBtn: 0,
                btnAlign: 'c'
                ,
                yes: function (index) {
                    $.get("houseDelete", {
                        contractId: "${(contract.id)!}",
                        houseId: obj.attr("houseId"),
                        _time: new Date().getTime()
                    }, function (data) {
                        if (data.code == "0001") {//成功
                            layer.msg(data.message, {anim: 0, icon: 1, time: 1000});
                        } else {//失败
                            layer.msg(data.message, {anim: 6, icon: 2, time: 2000});
                        }
                        loadSelectHouseInfo("${(contract.id)!}");
                    })
                }
            });
        });

        $(".storageRoomDelete").click(function () {
            var obj = $(this);
            layer.open({
                title: false,
                shade: 0.5,
                content: "确定撤销【" + obj.attr("buildNum") + "幢" + obj.attr("houseNum") + "】储藏室吗？",
                btn: ['确定', '取消'],
                closeBtn: 0,
                btnAlign: 'c'
                ,
                yes: function (index) {
                    $.get("storageRoomDelete", {
                        storageRoomId: obj.attr("storageRoomId"),
                        _time: new Date().getTime()
                    }, function (data) {
                        if (data.code == "0001") {//成功
                            layer.msg(data.message, {anim: 0, icon: 1, time: 1000});
                        } else {//失败
                            layer.msg(data.message, {anim: 6, icon: 2, time: 2000});
                        }
                        loadSelectHouseInfo("${(contract.id)!}");
                    })
                }
            });
        });

        $(".storageRoomAdd").click(function () {
            var houseId = $(this).attr("houseId");
            jmdf.view("storageRoomList?type=2&houseId=" + houseId, "80");
        })
    });
</script>